#include <bits/stdc++.h>
using namespace std;
int main(){
    string s1, s2;
    cin >> s1 >> s2;
    int a1 = 1, a2 = 1;
    for (int i = 0; i < s1.size(); i++){
        int t = s1[i] - 'A' + 1;
        a1 = a1 * t;
    }
    for (int i = 0; i < s2.size(); i++){
        int t = s2[i] - 'A' + 1;
        a2 = a2 * t;
    }
    a1 = a1 % 47;
    a2 = a2 % 47;
    if (a1 == a2){
        cout << "GO";
    }
    else{
        cout << "STAY";
    }
    return 0;
}